<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Sell Order</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="js/assets/jquery/jquery-1.10.2.min.js"></script>
<script src="js/assets/bootstrap/js/bootstrap.min.js"></script>
<script src="js/assets/prettify/run_prettify.js"></script>
<script src="js/assets/number-updown/js/updown.js"></script>
<script type="text/javascript">
$(function(){
    $('.source-code').each(function(index){
        var $section = $(this);
        var code =   $('#ql1').updown();     
        
        // Code preview
        var $codePreview = $('<pre class="prettyprint lang-javascript"></pre>');
        $codePreview.text(code);
        $section.html($codePreview);
        
        // Run code
        eval(code);
    });
});
</script>
<script>

function onSelect(){
	if (document.sellform.otype.value == "SL")
	{
	document.sellform.tp1.disabled = false;
	}else{
	document.sellform.tp1.disabled = true;
	}
	}
</script>

<script type="text/javascript">
$(document).ready(function() { 
	
	$(submit).click(function(event) { 
	
	var reqUrl = "./order/sellOrder";
	var userId= ('<sec:authentication property="principal.username"/>').replace('&#32;',' ');
	alert(userId);
	$.ajax(
		  {
		  type: "POST",
		  url: reqUrl,
		  dataType: "json",
		  contentType: 'application/json',
		  
		  data: JSON.stringify({ "otype":$("#otype").val(),"insname":$("#insname").val(),"symbol":$("#symbol").val(),"expdate":$("#expdate").val(),"qt":$("#qt").val(),"ql":$("#ql").val(),"qw":$("#qw").val(),"price":$("#price").val(),"ptype":$("#ptype").val(),"tp":$("#tp").val(),"userId":userId}),
		  success: function(html) { 			 
		    alert(html);
		  }
		  
		});
	});
});
</script>

<style>
body{ background:#FF6666;}
</style>
</head>
<body>
<h2>Buy and Sell For User "
	<sec:authentication property="principal.username" />"
	</h2>
<select id="orderType">
 
 <option value="SELL">Sell</option>
</select>
<form name="sellform" id="orderForm" method="post" action="./sell">
<table>
<tr>
<td><font color="white"><u>X</u></font></td>
<td><font color="white"><u>T</u>ype</font></td>
<td><font color="white"><u>I</u>nstr. Name</font></td>
<td><font color="white">S<u>y</u>mbol</font></td>
<td><font color="white">E<u>x</u>piry Date</font></td>
<td><font color="white">Total<u>Q</u>ty</font></td>
<td><font color="white">Total<u>L</u>ot</font></td>
<td><font color="white">Total<u>W</u>t</font></td>
<td><font color="white">P<u>r</u>ice</font></td>
</tr>
<tr>
<td><select>
<option>NMCEX</option>
</select></td>

<td><select onchange="onSelect();" id="otype" name="otype">
<option value="RL">RL</option>

<option value="SL">SL</option>
</select></td>

<td><input type="text" id="insname" name="insname" readonly="readonly" value="12345"></input></td>
<td><input type="text" id="symbol" name="symbol" readonly="readonly" value="Zinc"></input></td>
<td><select id="expdate" name="expdate">
<option value="30APR2014">30APR2014</option>
<option value="31MAY2014">31MAY2014</option>

</select></td>
<td><input type="text" id="qt" name="qt" readonly="readonly" value="1"></input></td>
<td>  <div class="source-code" style="display:none;">	
    </div>
    <div class="demo">
        <input type="text" class="form-control demo-input" id="ql" name="ql" value="1" />
    </div>
</td>
<td><input type="text" id="qw" name="qw" readonly="readonly" value="1"></input></td>
<td><input type="text" id="price" name="price" readonly="readonly" value="48520"></input></td>
</tr>
<tr>
<td><font color="white"><u>D</u>is. Qty</font></td>
<td><font color="white"><u>D</u>is. Lot</font></td>
<td><font color="white"><u>D</u>is. Weight</font></td>
<td><font color="white">Prod<u>u</u>ct Type</font></td>
<td><font color="white"><u>Trig</u>. Price</font></td>
<td><font color="white"><u>V</u>alidity</font></td>
<td><font color="white">User Re<u>m</u>ark</font></td>
</tr>
<tr>
<td><input type="text"  readonly="readonly"></input></td>
<td><input type="text"  readonly="readonly"></input></td>
<td><input type="text"  readonly="readonly"></input></td>
<td><select id="ptype" name="ptype">
<option value="Intra">Intra</option>
<option value="CarryForward">CarryForward</option>
</select></td>
<td><input type="text" id="tp" name="tp" disabled value="11111"></input></td>
<td><select>
<option>Day</option>
<option></option>
</select></td>
<td><input type="text"  readonly="readonly"></input></td>
<td><input type="text"  readonly="readonly"></input></td>
</tr>
<tr>
<td>
<input type="button" id="submit" value="Save" />
</td>
</tr>
</table>
</form>
</body>
</html>

